package com.ibm.eg.cvmanager.dao.impl;

// Generated Jul 28, 2011 12:17:35 PM by Hibernate Tools 3.4.0.CR1

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.hibernate.engine.query.HQLQueryPlan;
import org.hibernate.hql.ast.HqlASTFactory;

import com.ibm.eg.cvmanager.dao.util.HibernateUtil;
import com.ibm.eg.cvmanager.dto.Applicant;

import exception.TechnicalException;

/**
 * Home object for domain model class Applicant.
 * @see com.ibm.eg.cvmanager.dao.impl.Applicant
 * @author Hibernate Tools
 */
public class ApplicantDao extends BaseDao{

	private static final Log log = LogFactory.getLog(ApplicantDao.class);

	public ArrayList<Applicant> filterApplicants(String name) throws TechnicalException
	{
		ArrayList<Applicant> applicants;
		Session session = HibernateUtil.getCurrentSession();
		log.debug("filtering Applicants by name");
		try{
			applicants = (ArrayList<Applicant>) session.createCriteria(Applicant.class)
				.add(Restrictions.like("name", name, MatchMode.ANYWHERE)).list();
			log.debug("filter successful");
			return applicants;
		}
		catch(HibernateException ex)
		{
			log.error("filter failed", ex);

			throw new TechnicalException("filterApplicants(String name) error in ApplicantDao",ex);
		}
	}
}
